package request;

import core.Constants;
import core.GameCharacter;
import core.GameUser;
import core.Message;

import java.io.OutputStream;
import java.util.Vector;
import response.ResponseUpdateChatPrivate;

/**
 * RequestUpdateChatPrivate
 * @author brian
 */
public class RequestUpdateChatPrivate extends GameRequest {

    private GameUser user;
    private GameCharacter character;
    private int charID = -1;

    public RequestUpdateChatPrivate() {
        code = Constants.CMSG_GET_PRIVATE_CHAT;
    }

    @Override
    public void parse() {
        user = client.getUser();
        character = user.getCharacter();
        charID = character.getID();
    }

    public void respond(OutputStream output) {
        ResponseUpdateChatPrivate response = new ResponseUpdateChatPrivate();

        response.set(gameServer);
        response.setOut(output);
        response.setMessages(gameServer.getPrivateChats(user.getUsername()));
        gameServer.clearPrivateChats(user.getUsername());
        response.run();
    }
}
